package com.Interface.TestIO;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;

public class test5 {
    public static void main(String[] args) throws Exception {
        String path1 = "D:\\JAVA\\schoolSystem\\src\\com\\Interface\\TestIO\\file\\1.txt";
//        String path2 = "D:\\JAVA\\schoolSystem\\src\\com\\Interface\\TestIO\\file\\test2.txt";
        InputStream inputStream = new FileInputStream(path1);

        Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        StringBuffer stringBuffer = new StringBuffer();

//        char[] chars = new char[inputStream.available()];
        char[] chars = new char[1024];

        int bytesRead;
        while ((bytesRead = reader.read(chars)) != -1){
//            stringBuffer.append(chars);
            for (int i = 0; i < chars.length; i++) {
                if (chars[i] != '\u0000'){
                    System.out.print(chars[i]);
                }
            }
        }

        System.out.println(stringBuffer.toString());
//        for (char aChar : chars) {
//            if (aChar != ' ') {
//                System.out.print(aChar);
//            }
//        }
        reader.close();
        inputStream.close();
    }
}
